<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Swift_Mailer;
use Swift_Message;
use Swift_SendmailTransport;
use Swift_SmtpTransport;

class SendMailController extends Controller
{
    //
    public function index()
    {
        // Create the Transport
        //$transport = (new Swift_SmtpTransport('smtp.126.com', 25))
        //    ->setUsername ('liaochunkhgm@126.com')
        //    ->setPassword ('liao19901201');
        $transport = new Swift_SendmailTransport('/usr/sbin/sendmail -bs');
        // Create the Mailer using your created Transport
        $mailer = new Swift_Mailer($transport);

        // Create a message
        $message = (new Swift_Message('Hello，在吗'))
            ->setFrom (['liaochunkhgm@126.com' => 'Liao'])
            ->setTo (['liaodeity@foxmail.com'])
            ->setBody ('最近好吗？');

        // Send the message
        $result = $mailer->send ($message);
        dd ($result);
    }
}
